package com.heima.admin.controller;
// 爱情不是随便许诺,算了,不想再说了

import com.heima.admin.service.AdChannelService;
import com.heima.admin.service.AdUserService;
import com.heima.common.dtos.PageResult;
import com.heima.common.dtos.ResponseResult;
import com.heima.model.admin.dtos.ChannelDto;
import com.heima.model.media.dtos.WmNewsResultDTO;
import com.heima.model.user.dtos.AuthDto;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class NewsAuthController {


    @Autowired
    private AdChannelService channelService;

    /*
     * 分页查询自媒体
     * @param dto
     * @return
     */
    @PostMapping("/api/v1/news_auth/list")
    public PageResult<WmNewsResultDTO> list(@RequestBody ChannelDto dto) {
        return channelService.findByAllPage(dto);
    }


    /**
     * 文章详情--(id查询)
     *
     * @param id
     * @return
     */
    @GetMapping("/api/v1/news_auth/one/{id}")
    public ResponseResult<WmNewsResultDTO> findById(@PathVariable("id") Integer id) {
        WmNewsResultDTO wmNewsResultDTO = channelService.findById(id);
        return ResponseResult.ok(wmNewsResultDTO);
    }


    /**
     * 审核不通过
     *
     * @param dto
     * @return
     */
    @PostMapping("/api/v1/news_auth/auth_fail")
    public ResponseResult updateStatusNo(@RequestBody AuthDto dto) {
        channelService.updateStatusNo(dto);
        return ResponseResult.ok();

    }

    /**
     * 审核通过
     *
     * @param dto"
     * @return
     */
    @PostMapping("/api/v1/news_auth/auth_pass")
    public ResponseResult updateStatusOk(@RequestBody AuthDto dto) {
        channelService.updateStatusOk(dto);
        return ResponseResult.ok();

    }
}
